import sys
import requests
from requests_toolbelt import MultipartEncoder

def uploadImage(image):
    url = "https://open.feishu.cn/open-apis/im/v1/images"
    form = {'image_type': 'message',
            'image': (open(image, 'rb'))}  # 需要替换具体的path 
    multi_form = MultipartEncoder(form)
    headers = {
        'Authorization': getAccessToken(),  ## 获取tenant_access_token, 需要替换为实际的token
    }
    headers['Content-Type'] = multi_form.content_type
    response = requests.request("POST", url, headers = headers, data = multi_form)
    print(response.headers['X-Tt-Logid'])  # for debug or oncall
    print(response.content)  # Print Response

def getAccessToken():
    return ''

if __name__ == '__main__':
    argvs = sys.argv
    uploadImage(argvs[1])